package com.caijin.web.controller.system.menu;

import com.caijin.common.core.domain.Result;
import com.caijin.system.service.IMenuService;
import com.caijin.common.util.ListToTree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author Peas
 * @since 2021-01-06
 */
@RestController
@RequestMapping("/system/menu")
@CrossOrigin
public class MenuController {

    @Autowired
    private IMenuService iMenuService;

    /**
     * 获取主页面菜单
     */
    @RequestMapping(method = RequestMethod.GET,path = "/main")
    public Result getMenu(){
        return ListToTree.menuToTree(iMenuService.list());
    }

    /**
     * 获取课程页面菜单
     */
    @RequestMapping(method = RequestMethod.GET,path = "/course")
    public Result getMenuForCourse(){
        return ListToTree.menuToTreeForCourse(iMenuService.list());
    }
}

